package com.blockmeta.bbs.immodule.modelimpl;

import com.blockmeta.bbs.businesslibrary.baselist.BaseBean;
import com.blockmeta.bbs.businesslibrary.baselist.BaseListModelImpl;
import com.blockmeta.bbs.businesslibrary.net.retrofit.RetrofitFactory;
import com.blockmeta.bbs.businesslibrary.util.AccountHelper;
import com.blockmeta.bbs.immodule.bean.LibraryBookBean;
import com.blockmeta.bbs.immodule.bean.MyForumPostsPOJO;
import com.blockmeta.bbs.immodule.net.api.GetMyForumPostApi;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import io.reactivex.Flowable;

public class MyForumPostModelImpl extends BaseListModelImpl<MyForumPostsPOJO> {

    @Override
    public Flowable<MyForumPostsPOJO> ServiceParams(HashMap<String, String> params) {
        return RetrofitFactory.getRetrofit().create(GetMyForumPostApi.class).getMyForumPost(params);
    }

    @Override
    public void SuccessOperation(BaseBean o) {
        MyForumPostsPOJO myForumPostsPOJO = (MyForumPostsPOJO) o;
        if(myForumPostsPOJO != null){
            List<?> datas = myForumPostsPOJO.getList();
            if(datas != null && datas.size() > 0){
                if(isMore){
                    loadListeners.getDataMore(datas);
                }else {
                    loadListeners.getDataRefresh(datas);
                }
            }else {
                loadListeners.hasNoMoreData();
            }
        }else {

        }
    }

    @Override
    public HashMap<String, String> getParams() {
        HashMap<String, String> params = super.getParams();
        params.put("num", "10");
        params.put("authorid", AccountHelper.getUid());
        return mParams;
    }


}
